package com.lh.controller;

import com.lh.pojo.Stu;
import com.lh.service.StuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: foodie-dev
 * @description:
 * @author: LH
 * @create: 2022-03-18 14:18
 **/
@RequestMapping("test")
@RestController
//@ApiIgnore
public class StuController {

    private static final Logger LOG = LoggerFactory.getLogger(StuController.class);

    @Autowired
    private StuService stuService;

    @GetMapping("/getStu")
    public Stu getStu(int id){

        LOG.info("info: hello");
        return stuService.getStu(id);
    }

    @GetMapping("/hello")
    public String getStu(){

        LOG.info("info: hello");
        return "Hello";
    }


    @PostMapping("/saveStu")
    public String saveStu(@RequestBody Stu stu){
        stuService.saveStu(stu);
        return "save";
    }

    @PostMapping("/updateStu")
    public String updateStu(@RequestBody Stu stu){
        stuService.updateStu(stu);
        return "update";
    }

    @PostMapping("/deleteStu")
    public String deleteStu(@RequestBody Integer id){
        stuService.deleteStu(id);
        return "delete";
    }

}
